package com.tunan.lsj.check.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.tunan.common.Result;
import com.tunan.lsj.check.IGenericCheck;
import com.tunan.lsj.check.exception.CheckException;

@Component("jzdmCk")
public class JzdmCheck extends IGenericCheck {
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	private static final String sql="select count(*) from t_jzdm where xzq= ? "; 

	@Override
	public Result check(String value) throws CheckException{
		if(StringUtils.isEmpty(value)){
			throw new CheckException("传入的参数值不能为空！");
		}
		int count = jdbcTemplate.queryForObject(sql,new Object[] {value},Integer.class);
		if (count == 0) throw new CheckException("传入的参数值在数据库中不存在！");
		return new Result();
	}
}
